{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/Data_building_part_1_print.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}22 May 2019, 11:48:01
{txt}
{com}. 
. * Set the Path
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_dataset.dta", clear
{txt}
{com}. 
. *******************************************
. * WAR + EXTERNAL DEFAULT
. ********************************************
. 
. * Number of years at war between 1816-1913
. bysort cowcode: egen years_external = total(external_war)
{txt}
{com}. 
. * War and Access
. bysort cowcode: gen war_and_access_abroad = 0
{txt}
{com}. bysort cowcode: replace war_and_access_abroad = 1 if external_war == 1 & external_sdv == 0
{txt}(348 real changes made)

{com}. bysort cowcode: egen ty_war_and_external_kap_access = total(war_and_access_abroad)
{txt}
{com}. 
. * War while being in default
. bysort cowcode: gen war_and_default_abroad = 0
{txt}
{com}. bysort cowcode: replace war_and_default_abroad = 1 if external_war == 1 & external_sdv == 1
{txt}(51 real changes made)

{com}. bysort cowcode: egen ty_war_and_external_default = total(war_and_default_abroad)
{txt}
{com}. 
. 
. *******************************************************
. * WAR + DOMESTIC DEFAULT
. *******************************************************
. 
. gen either_default = 0 if (external_sdv == 0 & domestic_sdc == 0)
{txt}(5,129 missing values generated)

{com}. replace either_default = 1 if (external_sdv == 1 | domestic_sdc == 1)
{txt}(817 real changes made)

{com}. 
. * War and Access
. bysort cowcode: gen war_and_access_either = 0
{txt}
{com}. bysort cowcode:replace war_and_access_either = 1 if external_war == 1 & either_default == 0
{txt}(345 real changes made)

{com}. bysort cowcode: egen ty_war_and_either_kap_access = total(war_and_access_either)
{txt}
{com}. 
. * War while being in default
. bysort cowcode: gen war_and_default_either = 0
{txt}
{com}. bysort cowcode: replace war_and_default_either = 1 if external_war == 1 & either_default == 1
{txt}(54 real changes made)

{com}. bysort cowcode: egen ty_war_and_either_default = total(war_and_default_either)
{txt}
{com}. 
. *******************************************************
. * WAR + MONETARIZATION 
. *******************************************************
. 
. gen inflation_with_lead = . 
{txt}(10,486 missing values generated)

{com}. replace inflation_with_lead = 1 if inflation_crisis == 1
{txt}(190 real changes made)

{com}.         
. tsset cowcode year
{res}{txt}{col 8}panel variable:  {res}cowcode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1816 to 1913
{txt}{col 17}delta:  {res}1 unit
{txt}
{com}.         
. replace inflation_with_lead = 1 if l.inflation_crisis == 1
{txt}(158 real changes made)

{com}. replace inflation_with_lead = 1 if l.l.inflation_crisis == 1
{txt}(148 real changes made)

{com}. replace inflation_with_lead = 1 if l.l.l.inflation_crisis == 1
{txt}(124 real changes made)

{com}. replace inflation_with_lead = 1 if l.l.l.l.inflation_crisis == 1
{txt}(107 real changes made)

{com}. replace inflation_with_lead = 0 if inflation_with_lead == . 
{txt}(9,759 real changes made)

{com}. 
. * War while being in default AND monetarization
. bysort cowcode: gen war_and_default_with_monet = 0
{txt}
{com}. bysort cowcode: replace war_and_default_with_monet = 1 if external_war == 1 & external_sdv == 1 & inflation_with_lead == 1
{txt}(9 real changes made)

{com}. bysort cowcode: egen ty_war_and_default_with_monet = total(war_and_default_with_monet)
{txt}
{com}. 
. 
. * War while being in default AND NO monetarization
. bysort cowcode: gen war_and_default_no_monet = 0
{txt}
{com}. bysort cowcode: replace war_and_default_no_monet = 1 if external_war == 1 & external_sdv == 1 & inflation_with_lead == 0
{txt}(42 real changes made)

{com}. bysort cowcode: egen ty_war_and_default_no_monet = total(war_and_default_no_monet)
{txt}
{com}. 
.         
. 
. 
. **********************************************************************************
. * FINANCIAL CRISIS IN THE UK, THE BANKER OF THE WORLD - UK  (Reinhart & Rogoff)
. **********************************************************************************
. 
. * List of banking and stock market crises 
. sort year
{txt}
{com}. list year if banking_crisis >= 1 & country == "United Kingdom"
{txt}
       {c TLC}{hline 6}{c TRC}
       {c |} {res}year {txt}{c |}
       {c LT}{hline 6}{c RT}
 1022. {c |} {res}1825 {txt}{c |}
 2278. {c |} {res}1837 {txt}{c |}
 2369. {c |} {res}1838 {txt}{c |}
 2553. {c |} {res}1839 {txt}{c |}
 2649. {c |} {res}1840 {txt}{c |}
       {c LT}{hline 6}{c RT}
 3406. {c |} {res}1847 {txt}{c |}
 3491. {c |} {res}1848 {txt}{c |}
 3563. {c |} {res}1849 {txt}{c |}
 3663. {c |} {res}1850 {txt}{c |}
 4395. {c |} {res}1857 {txt}{c |}
       {c LT}{hline 6}{c RT}
 5415. {c |} {res}1866 {txt}{c |}
 7962. {c |} {res}1890 {txt}{c |}
       {c BLC}{hline 6}{c BRC}

{com}. list year if stock_market_crash >= 1 & country == "United Kingdom"
{txt}
       {c TLC}{hline 6}{c TRC}
       {c |} {res}year {txt}{c |}
       {c LT}{hline 6}{c RT}
 5346. {c |} {res}1865 {txt}{c |}
 5415. {c |} {res}1866 {txt}{c |}
 5540. {c |} {res}1867 {txt}{c |}
10127. {c |} {res}1910 {txt}{c |}
10271. {c |} {res}1911 {txt}{c |}
       {c LT}{hline 6}{c RT}
10299. {c |} {res}1912 {txt}{c |}
10381. {c |} {res}1913 {txt}{c |}
       {c BLC}{hline 6}{c BRC}

{com}. 
. ********* FOUR YEAR PERSISTENCE (BANKING and STOCK MARKET CRISIS)
. 
. sort year
{txt}
{com}. gen stop_4y = 0 
{txt}
{com}. replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}. replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. 
. ********* FIVE YEAR PERSISTENCE (BANKING and STOCK MARKET CRISIS)
. 
. sort year
{txt}
{com}. gen stop_5y = 0 
{txt}
{com}. replace stop_5y = 1 if year >=1825 & year<=1830
{txt}(642 real changes made)

{com}. replace stop_5y = 1 if year >=1837 & year<= 1845
{txt}(963 real changes made)

{com}. replace stop_5y = 1 if year >=1847 & year<= 1855
{txt}(963 real changes made)

{com}. replace stop_5y = 1 if year >=1857 & year<= 1862
{txt}(642 real changes made)

{com}. replace stop_5y = 1 if year >=1865 & year<=1872
{txt}(856 real changes made)

{com}. replace stop_5y = 1 if year >=1873 & year<= 1878
{txt}(642 real changes made)

{com}. replace stop_5y = 1 if year >=1890 & year<= 1895
{txt}(642 real changes made)

{com}. replace stop_5y = 1 if year >=1910 & year<= 1915
{txt}(428 real changes made)

{com}. 
. 
. ********* SIX YEAR PERSISTENCE (BANKING and STOCK MARKET CRISIS)
. 
. sort year
{txt}
{com}. gen stop_6y = 0 
{txt}
{com}. replace stop_6y = 1 if year >=1825 & year<=1831
{txt}(749 real changes made)

{com}. replace stop_6y = 1 if year >=1837 & year<= 1845
{txt}(963 real changes made)

{com}. replace stop_6y = 1 if year >=1847 & year<= 1856
{txt}(1,070 real changes made)

{com}. replace stop_6y = 1 if year >=1857 & year<= 1863
{txt}(749 real changes made)

{com}. replace stop_6y = 1 if year >=1865 & year<=1873
{txt}(963 real changes made)

{com}. replace stop_6y = 1 if year >=1873 & year<= 1879
{txt}(642 real changes made)

{com}. replace stop_6y = 1 if year >=1890 & year<= 1896
{txt}(749 real changes made)

{com}. replace stop_6y = 1 if year >=1910 & year<= 1916
{txt}(428 real changes made)

{com}.  
. 
. ********************************************
. * EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN
. ********************************************
. 
. **** 4 Year Window
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(222 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while credit stops
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(243 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
.         
. **** 4 year window without 1873 crisis [for robustness]
. 
. gen stop_4y_no73 = stop_4y
{txt}
{com}. replace stop_4y_no73 = 0 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. * War and Access
.         bysort cowcode: gen war_and_flow_4y_no73 = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y_no73 = 1 if external_war == 1 & stop_4y_no73 == 0
{txt}(253 real changes made)

{com}.         bysort cowcode: egen ty_war_and_flow_4y_no73 = total(war_and_flow_4y_no73)
{txt}
{com}. 
. * War while being in default
.         bysort cowcode: gen war_and_stop_4y_no73 = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y_no73 = 1 if external_war == 1 & stop_4y_no73 == 1
{txt}(212 real changes made)

{com}.         bysort cowcode: egen ty_war_and_stop_4y_no73 = total(war_and_stop_4y_no73)
{txt}
{com}.         
. 
. **** 4 year window without 1910 crisis [for robustness]
. 
. gen stop_4y_no1910 = stop_4y
{txt}
{com}. replace stop_4y_no1910 = 0 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. * War and Access
.         bysort cowcode: gen war_and_flow_4y_no10 = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y_no10 = 1 if external_war == 1 & stop_4y_no1910 == 0
{txt}(238 real changes made)

{com}.         bysort cowcode: egen ty_war_and_flow_4y_no10 = total(war_and_flow_4y_no10)
{txt}
{com}. 
. * War while being in default
.         bysort cowcode: gen war_and_stop_4y_no10 = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y_no10 = 1 if external_war == 1 & stop_4y_no1910 == 1
{txt}(227 real changes made)

{com}.         bysort cowcode: egen ty_war_and_stop_4y_no10 = total(war_and_stop_4y_no10)
{txt}
{com}.         
.         
.         
. **** 5 Year Window [for robustness]
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_5y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_5y = 1 if external_war == 1 & stop_5y == 0
{txt}(193 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_5y = total(war_and_flow_5y)
{txt}
{com}. 
. * War while credit stops
.         bysort cowcode: gen war_and_stop_5y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_5y = 1 if external_war == 1 & stop_5y == 1
{txt}(272 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_5y = total(war_and_stop_5y)
{txt}
{com}.         
. 
. **** 6 Year Window [for robustness]
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_6y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_6y = 1 if external_war == 1 & stop_6y == 0
{txt}(163 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_6y = total(war_and_flow_6y)
{txt}
{com}. 
. * War while credit stops
.         bysort cowcode: gen war_and_stop_6y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_6y = 1 if external_war == 1 & stop_6y == 1
{txt}(302 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_6y = total(war_and_stop_6y)
{txt}
{com}.         
. 
. 
.                 
. *****************************************************
. * Ongoing Wars
. *****************************************************
. 
. * Step 1. Identify wars fought having access to credit in t but not t+1
. bysort cowcode: gen EXOG_ongoingwar_and_stop_4y = 0
{txt}
{com}. tsset cowcode year
{res}{txt}{col 8}panel variable:  {res}cowcode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1816 to 1913
{txt}{col 17}delta:  {res}1 unit
{txt}
{com}. sort cowcode year 
{txt}
{com}. bysort cowcode: gen forward_stop = f.stop_4y
{txt}(107 missing values generated)

{com}. bysort cowcode: gen forward_external_war = f.external_war
{txt}(107 missing values generated)

{com}. bysort cowcode: replace EXOG_ongoingwar_and_stop_4y = 1 if (external_war == 1 & stop_4y == 0) & (forward_external_war == 1 & forward_stop == 1)
{txt}(26 real changes made)

{com}. 
. * Step 2. War that began before a stop - Indicator wariable
. bysort id_state_and_war: egen ongoing_war = max(EXOG_ongoingwar_and_stop_4y)
{txt}
{com}. 
. * Step 3. Identify all the years for wars that began before stop
. replace EXOG_ongoingwar_and_stop_4y = war_and_stop_4y if ongoing_war == 1
{txt}(118 real changes made)

{com}.         
. * Step 4: The next code does the following: it does not count any war that begins while the credit market is down, regardless of when it ends or what happens in between. 
. bysort id_state_and_war: egen year_start = min(year)
{txt}
{com}. replace year_start = . if id_state_and_war == .
{txt}(10,021 real changes made, 10,021 to missing)

{com}. bysort id_state_and_war: gen exclude = 0 
{txt}
{com}. bysort id_state_and_war: replace exclude = 1 if external_war == 1 & stop_4y == 1 & year == year_start 
{txt}(81 real changes made)

{com}. bysort id_state_and_war: egen exclude_war = max(exclude)
{txt}
{com}. replace EXOG_ongoingwar_and_stop_4y = 0 if exclude_war == 1
{txt}(20 real changes made)

{com}. sort cowcode year
{txt}
{com}. bysort cowcode: egen total_years_ongoingwar_stop_4y = total(EXOG_ongoingwar_and_stop_4y)
{txt}
{com}. sum total_years_ongoingwar_stop_4y

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
to~r_stop_4y {c |}{res}     10,486    .6728972    2.286909          0         12
{txt}
{com}. 
. 
. 
. *******************************************
. * WHERE WAS WAR FOUGHT
. *******************************************
. 
. bysort country: gen at_war = 0
{txt}
{com}. bysort country: replace at_war = 1 if (external_war == 1)
{txt}(465 real changes made)

{com}. bysort country: egen total_years_at_war = total(at_war)
{txt}
{com}. 
. bysort country: gen war_at_home = 0 & at_war == 0
{txt}
{com}. bysort country: replace war_at_home = 1 if at_war == 1 & country == location1
{txt}(139 real changes made)

{com}. bysort country: replace war_at_home = 1 if at_war == 1 & country == location2
{txt}(48 real changes made)

{com}. bysort country: replace war_at_home = 1 if at_war == 1 & country == location3
{txt}(15 real changes made)

{com}. bysort country: replace war_at_home = 1 if at_war == 1 & country == location4
{txt}(1 real change made)

{com}. bysort country: replace war_at_home = 1 if at_war == 1 & country == location5
{txt}(0 real changes made)

{com}. 
. bysort country: gen war_abroad = 1 if at_war == 1
{txt}(10,021 missing values generated)

{com}. bysort country: replace war_abroad = 0 if at_war == 1 & (country == location1)
{txt}(139 real changes made)

{com}. bysort country: replace war_abroad = 0 if at_war == 1 & (country == location2)
{txt}(48 real changes made)

{com}. bysort country: replace war_abroad = 0 if at_war == 1 & (country == location3)
{txt}(15 real changes made)

{com}. bysort country: replace war_abroad = 0 if at_war == 1 & (country == location4)
{txt}(1 real change made)

{com}. bysort country: replace war_abroad = 0 if at_war == 1 & (country == location5)
{txt}(0 real changes made)

{com}. 
. bysort country: egen total_years_war_at_home = total(war_at_home)
{txt}
{com}. gen total_years_war_at_home_share = total_years_war_at_home/total_years_at_war
{txt}(5,782 missing values generated)

{com}. replace total_years_war_at_home_share = 0 if total_years_at_war == 0
{txt}(5,782 real changes made)

{com}. 
. bysort country: egen total_years_war_abroad = total(war_abroad)
{txt}
{com}. gen total_years_war_abroad_share = total_years_war_abroad/total_years_at_war
{txt}(5,782 missing values generated)

{com}. replace total_years_war_abroad_share = 0 if total_years_at_war == 0
{txt}(5,782 real changes made)

{com}. 
. * New War Abroad
. gen net_war_abroad = total_years_war_abroad - total_years_war_at_home
{txt}
{com}. 
. 
. **********************
. *  CIVIL WAR
. **********************
. 
. * Civil war might be endogenous to external war.
. * I recode civil war to 0 if it coincides in time with external war
. replace civil_war = 0 if external_war == 1
{txt}(39 real changes made)

{com}. * Sum of all civil war years fought in a country over the cyle. 
. bysort cowcode: egen n_civil_wars = total(civil_war)
{txt}
{com}. 
. save "intermediate_step.dta", replace
{txt}(note: file intermediate_step.dta not found)
file intermediate_step.dta saved

{com}. 
. ****************************************
. * AVERAGE DURATION OF INTER-STATE WAR
. ****************************************
. 
. use "intermediate_step.dta", clear
{txt}
{com}. 
. keep country cowcode id_state_and_war
{txt}
{com}. drop if id_state_and_war == . 
{txt}(10,021 observations deleted)

{com}. bysort id_state_and_war: gen length = _N
{txt}
{com}. replace length = . if id_state_and_war == .
{txt}(0 real changes made)

{com}. drop if length == . 
{txt}(0 observations deleted)

{com}. bysort id_state_and_war: gen newid =_n
{txt}
{com}. keep if newid==1
{txt}(296 observations deleted)

{com}. bysort country: egen mean_duration = mean(length)
{txt}
{com}. bysort country: gen case = _n
{txt}
{com}. keep if case == 1
{txt}(121 observations deleted)

{com}. keep cowcode mean_duration
{txt}
{com}. save "mean_duration.dta", replace
{txt}(note: file mean_duration.dta not found)
file mean_duration.dta saved

{com}. 
. use "intermediate_step.dta", clear
{txt}
{com}. merge m:1 cowcode using "mean_duration.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}           5,782
{txt}{col 9}from master{col 30}{res}           5,782{txt}  (_merge==1)
{col 9}from using{col 30}{res}               0{txt}  (_merge==2)

{col 5}matched{col 30}{res}           4,704{txt}  (_merge==3)
{col 5}{hline 41}

{com}. replace mean_duration = 0 if mean_duration == . & external_war == 0
{txt}(5,782 real changes made)

{com}. drop _merge
{txt}
{com}. 
. 
. ****************************************************
. *  TOTAL YEARS IN DEFAULT (Reinhart and Rogoff)
. ****************************************************
. 
. bysort cowcode: egen total_years_default = total(external_sdv)
{txt}
{com}. save "country_year_format_main.dta", replace
{txt}(note: file country_year_format_main.dta not found)
file country_year_format_main.dta saved

{com}. 
. 
. ****************************************
. * KEEP ONE ENTRY PER COUNTRY 
. ****************************************
. 
. use "country_year_format_main.dta", clear
{txt}
{com}. 
. bysort cowcode: gen count = _n
{txt}
{com}. keep if count == 1
{txt}(10,379 observations deleted)

{com}. drop count
{txt}
{com}. 
. keep country cowcode net_war_abroad mean_duration total_years_default total_years_ongoingwar_stop_4y total_years_war_and_flow_4y total_years_war_and_stop_4y ty_war_and_flow_4y_no73 ty_war_and_stop_4y_no73 total_years_war_and_flow_5y total_years_war_and_stop_5y total_years_war_and_flow_6y total_years_war_and_stop_6y ty_war_and_external_default rr_sample ty_war_and_external_kap_access ty_war_and_external_default ty_war_and_either_kap_access ty_war_and_either_default ty_war_and_default_with_monet ty_war_and_default_no_monet ty_war_and_stop_4y_no10 ty_war_and_flow_4y_no10 years_external n_civil
{txt}
{com}. 
. save "war_and_suddenstop_1816_1913.dta", replace
{txt}(note: file war_and_suddenstop_1816_1913.dta not found)
file war_and_suddenstop_1816_1913.dta saved

{com}. 
. 
. *************************************************
. * MERGE SUDDEN STOP DATA WITH HOST OF CONTROLS
. *************************************************
. 
. use "war_and_suddenstop_1816_1913.dta", clear
{txt}
{com}. 
. merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. * Default Data for Analysis File
. save "data_for_main_analysis.dta", replace
{txt}(note: file data_for_main_analysis.dta not found)
file data_for_main_analysis.dta saved

{com}. 
. 
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. ******* 
. ******* CREATE DATASET RESTRICTED TO SOVEREIGN COUNTRIES
. ******* 
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. 
. clear all
{res}{txt}
{com}. 
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_dataset.dta", clear
{txt}
{com}. 
. *** FILTER no. 1. Drop Countries that are not sovereign by the time they go to war
.         drop if sovereign == 0
{txt}(6,657 observations deleted)

{com}.         
. ***********************************************************
. * CREDIT CRUNCH IN BRITAIN (Reinhart & Rogoff)
. ***********************************************************
. 
. sort year
{txt}
{com}. gen stop_4y = 0 
{txt}
{com}. replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(128 real changes made)

{com}. replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(279 real changes made)

{com}. replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(303 real changes made)

{com}. replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(204 real changes made)

{com}. replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(304 real changes made)

{com}. replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(225 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(199 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(220 real changes made)

{com}. 
. 
. ********************************************
. * EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN
. ********************************************
. 
. **** 4 Year Window
. 
. * War while credit flows
. bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}. bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(173 real changes made)

{com}. bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}. 
. * War while credit stops
. bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}. bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(214 real changes made)

{com}. bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
. 
. ****************************************
. * KEEP ONE ENTRY PER COUNTRY 
. ****************************************
. 
. bysort cowcode: gen count = _n
{txt}
{com}. keep if count == 1
{txt}(3,779 observations deleted)

{com}. drop count
{txt}
{com}. 
. *************************************************
. * MERGE SUDDEN STOP DATA WITH HOST OF CONTROLS
. *************************************************
. 
. merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}              57
{txt}{col 9}from master{col 30}{res}               0{txt}  (_merge==1)
{col 9}from using{col 30}{res}              57{txt}  (_merge==2)

{col 5}matched{col 30}{res}              50{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. keep country cowcode avg_pit_95_05 total_years_war_and_flow_4y total_years_war_and_stop_4y region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower
{txt}
{com}. 
. save "data_for_main_analysis_sovereign.dta", replace
{txt}(note: file data_for_main_analysis_sovereign.dta not found)
file data_for_main_analysis_sovereign.dta saved

{com}. 
. 
. 
. 
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. ******* 
. ******* CREATE DATASET THAT INCLUDES SECESSIONIST WAR
. *******
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. 
. clear all
{res}{txt}
{com}. 
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_dataset.dta", clear
{txt}
{com}. 
. *** FILTER no. 2. Treat Secessionist War as External War
.         replace external_war = 1 if secession_war == 1
{txt}(150 real changes made)

{com}. 
. 
. ***********************************************************
. * CREDIT CRUNCH IN BRITAIN (Reinhart & Rogoff)
. ***********************************************************
. 
. sort year
{txt}
{com}. gen stop_4y = 0 
{txt}
{com}. replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}. replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. 
. ********************************************
. * EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN
. ********************************************
. 
. **** 4 Year Window
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(313 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while credit stops
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(302 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
. save "country_year_format_secession.dta", replace
{txt}(note: file country_year_format_secession.dta not found)
file country_year_format_secession.dta saved

{com}. 
. 
. ****************************************
. * KEEP ONE ENTRY PER COUNTRY 
. ****************************************
. 
. use "country_year_format_secession.dta", clear
{txt}
{com}. 
. bysort cowcode: gen count = _n
{txt}
{com}. keep if count == 1
{txt}(10,379 observations deleted)

{com}. drop count
{txt}
{com}. 
. 
. *************************************************
. * MERGE SUDDEN STOP DATA WITH HOST OF CONTROLS
. *************************************************
. 
. merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. keep country cowcode avg_pit_95_05 total_years_war_and_flow_4y total_years_war_and_stop_4y region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower
{txt}
{com}. 
. save "data_for_main_analysis_secession.dta", replace
{txt}(note: file data_for_main_analysis_secession.dta not found)
file data_for_main_analysis_secession.dta saved

{com}. 
. 
. 
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. ******* 
. ******* CREATE DATASET WHICH DROPS BRITISH WAR
. *******
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. *******************************************************************
. 
. clear all
{res}{txt}
{com}. 
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_dataset.dta", clear
{txt}
{com}. 
. *** FILTER no. 3 Drop wars participated by Britain (as established by Wimmer and Min)
.         drop if British_war == 1
{txt}(121 observations deleted)

{com}. 
. 
. ***********************************************************
. * CREDIT CRUNCH IN BRITAIN (Reinhart & Rogoff)
. ***********************************************************
. 
. * For list see Figure 
. sort year
{txt}
{com}. list year if banking_crisis >= 1 & country == "United Kingdom"
{txt}
       {c TLC}{hline 6}{c TRC}
       {c |} {res}year {txt}{c |}
       {c LT}{hline 6}{c RT}
 2268. {c |} {res}1837 {txt}{c |}
 7847. {c |} {res}1890 {txt}{c |}
       {c BLC}{hline 6}{c BRC}

{com}. list year if stock_market_crash >= 1 & country == "United Kingdom"
{txt}
       {c TLC}{hline 6}{c TRC}
       {c |} {res}year {txt}{c |}
       {c LT}{hline 6}{c RT}
10041. {c |} {res}1910 {txt}{c |}
10045. {c |} {res}1911 {txt}{c |}
10187. {c |} {res}1912 {txt}{c |}
10361. {c |} {res}1913 {txt}{c |}
       {c BLC}{hline 6}{c BRC}

{com}. 
. ********* FOUR YEAR PERSISTENCE (BANKING and STOCK MARKET CRISIS)
. 
. sort year
{txt}
{com}. gen stop_4y = 0 
{txt}
{com}. replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(531 real changes made)

{com}. replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(850 real changes made)

{com}. replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(823 real changes made)

{com}. replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(522 real changes made)

{com}. replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(743 real changes made)

{com}. replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(533 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(532 real changes made)

{com}. 
. 
. ********************************************
. * EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN
. ********************************************
. 
. **** 4 Year Window
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(168 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while credit stops
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(176 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
. 
. ****************************************
. * KEEP ONE ENTRY PER COUNTRY 
. ****************************************
. 
. bysort cowcode: gen count = _n
{txt}
{com}. keep if count == 1
{txt}(10,258 observations deleted)

{com}. drop count
{txt}
{com}. 
. *************************************************
. * MERGE SUDDEN STOP DATA WITH HOST OF CONTROLS
. *************************************************
. 
. merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. keep country cowcode avg_pit_95_05 total_years_war_and_flow_4y total_years_war_and_stop_4y region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist census_1820
{txt}
{com}. 
. save "data_for_main_analysis_nonBritishwar.dta", replace
{txt}(note: file data_for_main_analysis_nonBritishwar.dta not found)
file data_for_main_analysis_nonBritishwar.dta saved

{com}. 
. 
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. *******
. ******* CREATE DATASET THAT INCLUDES TENTATIVE MATCHES
. *******
. *********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. 
. 
. clear all
{res}{txt}
{com}. 
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_data_with_tentative.dta", clear
{txt}
{com}. 
. ***********************************************************
. * CREDIT CRUNCH IN BRITAIN (Reinhart & Rogoff)
. ***********************************************************
. 
. sort year
{txt}
{com}. gen stop_4y = 0 
{txt}
{com}. replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}. replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}. replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}. replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. ********************************************
. * EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN
. ********************************************
. 
. **** 4 Year Window
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(230 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while credit stops
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(259 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
. ****************************************
. * KEEP ONE ENTRY PER COUNTRY 
. ****************************************
. 
. bysort cowcode: gen count = _n
{txt}
{com}. keep if count == 1
{txt}(10,379 observations deleted)

{com}. drop count
{txt}
{com}. 
. merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. keep country cowcode avg_pit_95_05 total_years_war_and_flow_4y total_years_war_and_stop_4y region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower state census_1820 
{txt}
{com}. 
. save "data_for_main_analysis_with_tentative.dta", replace
{txt}(note: file data_for_main_analysis_with_tentative.dta not found)
file data_for_main_analysis_with_tentative.dta saved

{com}. 
. 
. 
. 
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. *******
. ******* CREATE DATASET WITH WAR DATA DRAWN FROM CORRELATES 
. ******* OF WAR (COW v.4.0) RATHER THAN WIMMER AND MIN
. *******
. *********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. 
. 
. ****************************************
. * PART 1. ALL WAR BY COW 
. ****************************************
. 
. use "war_by_COW.dta", clear
{txt}
{com}. 
. /* CREDIT CRUNCH WINDOWS */
. 
.         gen stop_4y = 0 
{txt}
{com}.         replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}.         replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. save "country_year_format_main_COW.dta", replace
{txt}(note: file country_year_format_main_COW.dta not found)
file country_year_format_main_COW.dta saved

{com}. 
. ****** The following descriptives are summarized in the text
. ****** in Section 5.3 (there is no specific table)
.  
.         * # COW inter-state conflicts
.                 use "country_year_format_main_COW.dta", clear
{txt}
{com}.                 egen cow_war_county = group(inter_war_number_COW)
{txt}(10314 missing values generated)

{com}.                 tab cow_war_county

{txt}group(inter {c |}
_war_number {c |}
      _COW) {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          1 {c |}{res}          2        1.16        1.16
{txt}          2 {c |}{res}          4        2.33        3.49
{txt}          3 {c |}{res}          4        2.33        5.81
{txt}          4 {c |}{res}          6        3.49        9.30
{txt}          5 {c |}{res}          4        2.33       11.63
{txt}          6 {c |}{res}          1        0.58       12.21
{txt}          7 {c |}{res}          4        2.33       14.53
{txt}          8 {c |}{res}         16        9.30       23.84
{txt}          9 {c |}{res}          3        1.74       25.58
{txt}         10 {c |}{res}          4        2.33       27.91
{txt}         11 {c |}{res}          4        2.33       30.23
{txt}         12 {c |}{res}          2        1.16       31.40
{txt}         13 {c |}{res}         12        6.98       38.37
{txt}         14 {c |}{res}          2        1.16       39.53
{txt}         15 {c |}{res}          4        2.33       41.86
{txt}         16 {c |}{res}         20       11.63       53.49
{txt}         17 {c |}{res}          5        2.91       56.40
{txt}         18 {c |}{res}          4        2.33       58.72
{txt}         19 {c |}{res}          4        2.33       61.05
{txt}         20 {c |}{res}          2        1.16       62.21
{txt}         21 {c |}{res}          4        2.33       64.53
{txt}         22 {c |}{res}         15        8.72       73.26
{txt}         23 {c |}{res}          2        1.16       74.42
{txt}         24 {c |}{res}          4        2.33       76.74
{txt}         25 {c |}{res}          2        1.16       77.91
{txt}         26 {c |}{res}          4        2.33       80.23
{txt}         27 {c |}{res}          2        1.16       81.40
{txt}         28 {c |}{res}          2        1.16       82.56
{txt}         29 {c |}{res}          5        2.91       85.47
{txt}         30 {c |}{res}          1        0.58       86.05
{txt}         31 {c |}{res}          4        2.33       88.37
{txt}         32 {c |}{res}          3        1.74       90.12
{txt}         33 {c |}{res}          3        1.74       91.86
{txt}         34 {c |}{res}          4        2.33       94.19
{txt}         35 {c |}{res}          3        1.74       95.93
{txt}         36 {c |}{res}          4        2.33       98.26
{txt}         37 {c |}{res}          3        1.74      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        172      100.00
{txt}
{com}.                 * 37 COW inter-state conflicts
.                 
.         * Total number of years and mean duration of war while credit flows with standard deviation: 
.                 use "country_year_format_main_COW.dta", clear
{txt}
{com}.                 keep if external_war == 1
{txt}(10,314 observations deleted)

{com}.                 keep if stop_4y == 0
{txt}(94 observations deleted)

{com}.                 bysort country inter_war_number_COW: gen mean_duration_credit = _n
{txt}
{com}.                 sum mean_duration_credit

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
mean_durat~t {c |}{res}         78    1.576923    1.038471          1          5
{txt}
{com}.                 * War-years while credit flows: 78 
.                 * Average duration: 1.57 years 
.         
.         * Total number of year and mean duration of war while credit stops with standard deviation: 
.                 use "country_year_format_main_COW.dta", clear
{txt}
{com}.                 keep if external_war == 1
{txt}(10,314 observations deleted)

{com}.                 keep if stop_4y == 1
{txt}(78 observations deleted)

{com}.                 bysort country inter_war_number_COW: gen mean_duration_no_credit = _n
{txt}
{com}.                 sum mean_duration_no_credit

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
mean_durat~t {c |}{res}         94    1.755319    1.232937          1          6
{txt}
{com}.                 * War-years while credit stops: 94 
.                 * Average duration: 1.23 years 
. 
.         * Total number of war-years: T
.                 use "country_year_format_main_COW.dta", clear
{txt}
{com}.                 keep if external_war == 1
{txt}(10,314 observations deleted)

{com}.                 egen count_war_number = group(inter_war_number_COW)
{txt}
{com}.                 sum count_war_number

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
count_war_~r {c |}{res}        172        17.5    9.647289          1         37
{txt}
{com}.                 * 172 inter-state war years
.                 * % of war-years while credit flows = 100*(78/172) = 45.34%
.                 * % of war-years while credit stops = 100*(94/172) = 54.65%
. 
. 
. 
. /* EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN */
. 
. use "country_year_format_main_COW.dta", clear
{txt}
{com}.         
. * War and Access [4 year windows]
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(78 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while being in default [4 year windows]
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(94 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}.         
.         sum total_years_war_and_stop_4y

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
total_y~p_4y {c |}{res}     10,486    .8785047    2.012721          0          8
{txt}
{com}. 
. /* Net Victory */
.         
.         gen war_won = 1 if inter_outcome == 1
{txt}(10,397 missing values generated)

{com}.         gen war_lost = 1 if inter_outcome == 2
{txt}(10,415 missing values generated)

{com}.         bysort cowcode: egen success = total(war_won) 
{txt}
{com}.         bysort cowcode: egen failure = total(war_lost) 
{txt}
{com}.         gen net_victory = success - failure 
{txt}
{com}.         replace net_victory = 0 if net_victory == .
{txt}(0 real changes made)

{com}.         
. /* Keep one unit per country */
. 
.         bysort cowcode: gen count = _n
{txt}
{com}.         keep if count == 1
{txt}(10,379 observations deleted)

{com}.         drop count
{txt}
{com}. 
.         keep country cowcode total_years_war_and_flow_4y total_years_war_and_stop_4y net_victory
{txt}
{com}. 
. /* MERGE SUDDEN STOP DATA WITH CONTROLS */
. 
.         merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop _merge
{txt}
{com}. 
. save "data_for_COW_full_sample.dta", replace 
{txt}(note: file data_for_COW_full_sample.dta not found)
file data_for_COW_full_sample.dta saved

{com}. 
. 
. ****************************************
. *  PART 2. WAR BY NONINITIATORS ONLY
. ****************************************
. 
. use "war_by_COW.dta", clear
{txt}
{com}. 
. /* Keep only wars in which the country was attacked (i.e. set war by initiator to 0) */
.  replace external_war = 0 if inter_initiator == 1
{txt}(72 real changes made)

{com}. 
. 
. /* SUDDEN-STOP WINDOWS */
. 
.         gen stop_4y = 0 
{txt}
{com}.         replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}.         replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. 
. /* EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN */
.         
. * War and Access [4 year windows]
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(45 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while being in default [4 year windows]
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(55 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}.         
. 
. /* Net Victory */
.         
.         gen war_won = 1 if inter_outcome == 1
{txt}(10,397 missing values generated)

{com}.         gen war_lost = 1 if inter_outcome == 2
{txt}(10,415 missing values generated)

{com}.         bysort cowcode: egen success = total(war_won) 
{txt}
{com}.         bysort cowcode: egen failure = total(war_lost) 
{txt}
{com}.         gen net_victory = success - failure 
{txt}
{com}.         replace net_victory = 0 if net_victory == .
{txt}(0 real changes made)

{com}.         
. /* Keep one unit per country */
. 
.         bysort cowcode: gen count = _n
{txt}
{com}.         keep if count == 1
{txt}(10,379 observations deleted)

{com}.         drop count
{txt}
{com}. 
.         keep country cowcode total_years_war_and_flow_4y total_years_war_and_stop_4y net_victory
{txt}
{com}. 
. /* MERGE SUDDEN STOP DATA WITH CONTROLS */
. 
.         merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop _merge
{txt}
{com}. 
. save "data_for_COW_noninitiators_sample.dta", replace 
{txt}(note: file data_for_COW_noninitiators_sample.dta not found)
file data_for_COW_noninitiators_sample.dta saved

{com}. 
. 
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. *******
. ******* CREATE DATASET TO PRODUCE FIGURE A-3    
. *******
. *********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. **********************************************************
. 
. * Figure A-3 includes tentative matches and secessionist war
. 
. clear all
{res}{txt}
{com}. 
. cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"
{res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication
{txt}
{com}. 
. use "war_default_data_with_tentative.dta", clear
{txt}
{com}. 
. **** Treat Secessionist War as External War
.         replace external_war = 1 if secession_war == 1
{txt}(150 real changes made)

{com}. 
. **** Number of years at war between 1816-1913
.         bysort cowcode: egen years_external = total(external_war)
{txt}
{com}. 
.         
. /* CREDIT CRUNCH IN BRITAIN (Reinhart & Rogoff) */      
.         
.         gen stop_4y = 0 
{txt}
{com}.         replace stop_4y = 1 if year >=1825 & year<=1829
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1837 & year<= 1844
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1847 & year<= 1854
{txt}(856 real changes made)

{com}.         replace stop_4y = 1 if year >=1857      & year<= 1861
{txt}(535 real changes made)

{com}.         replace stop_4y = 1 if year >=1865  & year<=1871
{txt}(749 real changes made)

{com}.         replace stop_4y = 1 if year >=1890 & year<= 1894
{txt}(535 real changes made)

{com}. 
. *** Add 1910, a stock market crisis
.         replace stop_4y = 1 if year >=1910 & year<= 1914
{txt}(428 real changes made)

{com}. 
. *** Add 1873 crisis, not considered in Reinhart and Rogoff. 
.         replace stop_4y = 1 if year >=1873 & year<= 1877
{txt}(535 real changes made)

{com}. 
. /* EXTERNAL WARS and CREDIT CRUNCH IN BRITAIN */
.  
. **** 4 Year Window
. 
. * War while credit flows
.         bysort cowcode: gen war_and_flow_4y = 0
{txt}
{com}.         bysort cowcode:replace war_and_flow_4y = 1 if external_war == 1 & stop_4y == 0
{txt}(321 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_flow_4y = total(war_and_flow_4y)
{txt}
{com}.         
. * War while credit stops
.         bysort cowcode: gen war_and_stop_4y = 0
{txt}
{com}.         bysort cowcode: replace war_and_stop_4y = 1 if external_war == 1 & stop_4y == 1
{txt}(318 real changes made)

{com}.         bysort cowcode: egen total_years_war_and_stop_4y = total(war_and_stop_4y)
{txt}
{com}. 
. /* KEEP ONE ENTRY PER COUNTRY */
.  
.         bysort cowcode: gen count = _n
{txt}
{com}.         keep if count == 1
{txt}(10,379 observations deleted)

{com}.         drop count
{txt}
{com}. 
.         merge 1:1 cowcode using "all_controls.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}             107{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop _merge
{txt}
{com}. 
.         keep country cowcode avg_pit_95_05 total_years_war_and_flow_4y total_years_war_and_stop_4y region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower state census_1820 years_external
{txt}
{com}. 
. save "data_for_main_analysis_with_tentative_and_secession.dta", replace
{txt}(note: file data_for_main_analysis_with_tentative_and_secession.dta not found)
file data_for_main_analysis_with_tentative_and_secession.dta saved

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/Data_building_part_1_print.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}22 May 2019, 11:48:02
{txt}{.-}
{smcl}
{txt}{sf}{ul off}